package unit3;

import java.util.Arrays;
import java.util.Scanner;

/**
 * 
 * @author asus
 *
 */
public class LotteryDraw {
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner in=new Scanner(System.in);
		
		System.out.println("How many numbers do you need to draw?");
		int k=in.nextInt();
		
		System.out.println("What is the highest numbers you can draw?");
		int n=in.nextInt();
		
//		fill an array with number 1 2 3 ……
		int[] number=new int[n];
		for(int x=0;x<number.length;x++){
			number[x]=x+1;
		}
		
//		draw k number and put them into a second array
		int[] result=new int[k];
		for(int x=0;x<number.length;x++){
//			make a random index between 0 and n-1
			int r=(int)Math.random()*n;
			
//			pick the element at the random location
			result[x]=number[x];
			
//			move the last element into the random location
			number[r]=number[n-1];
			n--;
		}
//		print the sorted array
		Arrays.sort(result);
		System.out.println("Bet the following combination .It'll make you rich!");
		for(int r:result){
			System.out.println(r);
		}
	}
}
